﻿using UnityEngine;

namespace Gp.Scripts.Core {
    /// <summary>
    /// 列表item，你自己写的列表item需要继承该类
    /// </summary>
    [RequireComponent(typeof(RectTransform))]
    public abstract class RecyclingListViewItem : MonoBehaviour {
        /// <summary>
        /// 循环列表
        /// </summary>
        public RecyclingListView ParentList { get; private set; }

        private int currentRow;

        /// <summary>
        /// 行号
        /// </summary>
        public int CurrentRow {
            get => currentRow;
        }

        private RectTransform _rectTransform;

        public RectTransform RectTransform {
            get {
                if (_rectTransform == null)
                    _rectTransform = GetComponent<RectTransform>();
                return _rectTransform;
            }
        }

        private void Awake() {
            _rectTransform = GetComponent<RectTransform>();
        }

        
        
        
        /// <summary>
        /// item更新事件响应函数
        /// </summary>
        public virtual void NotifyCurrentAssignment(RecyclingListView v, int row) {
            ParentList = v;
            currentRow = row;
        }
    }
}